package edu.calvin.djs32.cs214.interpreters.size;

import edu.calvin.cs214.hobbes2008.ApplicationTIR;
import edu.calvin.cs214.hobbes2008.HobbesTIR;
import edu.calvin.cs214.hobbes2008.HobbesTIRVisitor;
import edu.calvin.cs214.hobbes2008.IntegerTIR;
import edu.calvin.cs214.hobbes2008.StringTIR;
import edu.calvin.cs214.hobbes2008.TupleTIR;

public class Size implements HobbesTIRVisitor<Integer>{

	public Integer visitApplication(ApplicationTIR application) {
		return null;
	}

	public Integer visitInteger(IntegerTIR integer) {
		return 1;
	}

	public Integer visitString(StringTIR string) {
		return 1;
	}

	public Integer visitTuple(TupleTIR tuple) {
		int size = 1;
		for (HobbesTIR element : tuple) {
			size += element.accept(this);
		}
		return size;
	}

}
